#include<bits/stdc++.h>
using namespace std;
const int len=1e5+10;
const int len2=1e6+10;
int T,d[len2],v[len],a[len],p[len],e[len],ll[len2],rr[len2],sum,ans,L,V,n,m;
bool vis[len];
void dfs(int x,int sum){
	if(x>m){
		int ssum=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(vis[j]==1)
					continue;
	//			cout<<"sur1"<<endl;
				if(p[j]<d[i])
					continue;
				int vv=v[i]*v[i]+2*a[i]*(p[j]-d[i]);
				if(vv>V){
	//				cout<<i<<' '<<j<<endl;
					ssum++;
					break;
				}
			}
		}
	//	cout<<"*"<<ssum<<' '<<sum<<endl;
		if(ssum==sum){
			int s=0;
			for(int j=1;j<=m;j++){
				if(vis[j]==1)
					s++;
			}
			ans=max(ans,s);
		}
		return ;
	}
	vis[x]=1;
	dfs(x+1,sum);
	vis[x]=0;
	dfs(x+1,sum);
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	scanf("%d",&T);
	for(int t=1;t<=T;t++){
		memset(vis,0,sizeof(vis));
		memset(e,0,sizeof(e));
		memset(ll,0,sizeof(ll));
		memset(rr,0,sizeof(rr));
		ans=0;
		sum=0;
		int tagg=1;
		scanf("%d %d %d %d",&n,&m,&L,&V);
		for(int i=1;i<=n;i++){
			scanf("%d %d %d",&d[i],&v[i],&a[i]);
			if(a[i]<0)
				tagg=0;
		}
		for(int i=1;i<=m;i++){
			scanf("%d",&p[i]);
		}
		int sum=0;
		if(tagg==1){
			V=V*V;
			for(int i=1;i<=n;i++){
				if(p[m]<d[i])
					continue;
				int vv=v[i]*v[i]+2*a[i]*(p[m]-d[i]);
				if(vv>V)
					sum++;
			}
			if(sum==0)
				ans=m;
			else
				ans=m-1;
			printf("%d %d\n",sum,ans);
			continue;
		}
		if(n<=10){
			V=V*V;
			for(int i=1;i<=n;i++){
				if(p[m]<d[i])
					continue;
				int vv=0;
				if(a[i]>=0){
					vv=v[i]*v[i]+2*a[i]*(p[m]-d[i]);
					if(vv>V){
						sum++;
					}
				}
				else{
					int id=upper_bound(p+1,p+m+1,d[i])-p;
					vv=v[i]*v[i]+2*a[i]*(p[id]-d[i]);
					if(vv>V){
						sum++;
					}
				}
			}
			dfs(1,sum);
			printf("%d %d\n",sum,ans);
		}
		else{
			V=V*V;
			for(int i=1;i<=n;i++){
				if(p[m]<d[i])
					continue;
				int vv=0;
				if(a[i]>=0){
					vv=v[i]*v[i]+2*a[i]*(p[m]-d[i]);
					if(vv>V){
						sum++;
					}
				}
				else{
					int id=upper_bound(p+1,p+m+1,d[i])-p;
					vv=v[i]*v[i]+2*a[i]*(p[id]-d[i]);
					if(vv>V){
						sum++;
					}
				}
			}
			for(int i=1;i<=n;i++){
				if(a[i]>=0)
					e[i]=L;
				else{
					e[i]=(V-v[i]*v[i])/(2*a[i]);
					e[i]=min(e[i],L);
				}
			}
			int sta=0;
			for(int i=1;i<=n;i++){
				ll[d[i]]++;
				rr[e[i]]++;
			}
			for(int i=1;i<=L;i++){
				if(sta>0 && rr[i]>0){
					ans++;
					sta=0;
				}
				sta+=ll[i];
			}
			ans=m-ans;
			printf("%d %d\n",sum,ans);
		}
	}
	return 0;
}
